package com.ruoyi.workflow.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.utils.DeployService;
import org.apache.commons.io.FilenameUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;
import java.io.InputStream;
import java.util.zip.ZipInputStream;

@RestController
@RequestMapping("/processDefinition")
public class DeployController {

    @Resource
    private DeployService deployService;

    @PostMapping(value = "/uploadStreamAndDeployment")
    public AjaxResult<String> uploadStreamAndDeployment(@RequestParam("fileName") String fileName) throws IOException {
        String deploymentId = deployService.deployment(fileName, "单位注册流程");
        return AjaxResult.success(deploymentId);
    }

    @DeleteMapping(value = "/delete")
    public AjaxResult<String> delete(String deployId) throws IOException {
        System.out.println(deployId);
        deployService.deleteDeployment(deployId, true);
        return AjaxResult.success("删除成功");
    }
}
